#include <stdio.h>
#include <stdlib.h>

#include "nohead.h"
/* 实现无头结点的单向不循环链表的增加/删除*/
int main()
{
	struct node_st *list = NULL;
	struct score_st tmp;
	int i = 0,err = 0;
	for(i=0;i<7;i++)
	{
		tmp.id = i;
		snprintf(tmp.name,NAMESIZE,"stu%d",i);
		tmp.math = rand() % 100;
		tmp.chinese = rand() % 100;
		
	//	list_insert(list,&tmp);/* 函数原型：int list_insert(struct node_st *,struct score_st *) 此时无法改变node_st指针的内容 */
		err = list_insert(&list,&tmp);/* 函数原型：struct node_st *list_insert(struct node_st *,struct score_st *) / 传入二级指针(最优解)*/	
		if(err != 0)
			exit(1);

	}

	list_show(list);
	
	list_delete(&list);
	list_show(list);
	
	struct score_st *score;
	int id = 3;
	score =  list_find(list,id);
	if (score)
		printf("%d %s %d %d\n",score->id,score->name,score->math,score->chinese);
	else
		printf("Can`t find!\n");

	list_destroy(list);
	exit(0);
}
